
/********************************************************************************
* Title: Ambiguous Platforms and Correlated Preferences: Experimental Evidence
* Authors: Juha Tolvanen, James Tremewan, and Alexander K. Wagner
********************************************************************************/


*** -------------------------------- ****
* load data
** REPLCE PATH WITH LOCAL DATA PATH and load .dta file 
use ".../final_dataset.dta"

*SET TIME-SERIES
*xtset subjectid period
*SET GLOBAL OPTIONS FOR GRAPH EXPORTING
* 
*ssc install blindschemes
*ssc install grstyle, replace
set scheme plottig, permanently
grstyle init
grstyle set size large: axis_title tick_label heading subheading
*** -------------------------------- ***



*** ----------------------------------------------------------------------- ***
***      Population characteristics and heterogeneity in rationality		*** 
*** ----------------------------------------------------------------------- ***


**********************************************
*** Table 1: Summary statistics candidates ***
**********************************************

estpost tabstat age female updateexact level1plus risk  if(period==1 & role==1 & incumbent==0 ), /// 
statistics(mean sd) columns(statistics) listwise 
est store T0

estpost tabstat age female updateexact level1plus risk  if(period==1 & role==1 & incumbent==1 ), /// 
statistics(mean sd) columns(statistics) listwise 
est store T1

estpost tabstat age female updateexact level1plus risk  if(period==1 & role==1 ), /// 
statistics(mean sd) columns(statistics) listwise 
est store T2

* output in stata
esttab T0 T1 T2, cells("mean sd") label mtitles("Treat BL" "Treat KC" "Pooled")  title("Candidates")
* output to tex
*esttab T0 T1 T2 using Table1.tex, cells(" mean(fmt(%5.2f)) sd(fmt(%5.2f))") label mtitles("Treat BL" "Treat KC")  title("Candidates (n=80 per treat)") replace

** difference between BL and KC for candidates
* ttest
estpost ttest  age female updateexact level1plus risk if(period==1 & role==1), by(incumbent)
* ranksum
ranksum age 		if(period==1 & role==1), by(incumbent)
ranksum female 		if(period==1 & role==1), by(incumbent)
ranksum updateexact if(period==1 & role==1), by(incumbent)
ranksum level1plus 	if(period==1 & role==1), by(incumbent)
ranksum risk 		if(period==1 & role==1), by(incumbent)




******************************************
*** Table 2: Summary statistics voters ***
******************************************

estpost tabstat age female updateexact level1plus risk  if(period==1 & role==2 & incumbent==0 ), /// 
statistics(count mean sd) columns(statistics) listwise 
est store T0

estpost tabstat age female updateexact level1plus risk  if(period==1 & role==2 & incumbent==1 ), /// 
statistics(count mean sd) columns(statistics) listwise 
est store T1

estpost tabstat age female updateexact level1plus risk  if(period==1 & role==2 ), /// 
statistics(count mean sd) columns(statistics) listwise 
est store T2

* output in stata
esttab T0 T1 T2, cells("mean sd") label mtitles("Treat BL" "Treat KC" "Pooled") title("Voters")
* output to tex
*esttab T0 T1 T2 using Table2.tex, cells("mean(fmt(%5.2f)) sd(fmt(%5.2f))") label mtitles("Treat BL" "Treat KC") title("Voters (n=120 per treat)") replace


** difference between BL and KC for voters
* ttest
estpost ttest  age female updateexact level1plus risk if(period==1 & role==2), by(incumbent)
* ranksum
ranksum age 		if(period==1 & role==2), by(incumbent)
ranksum female 		if(period==1 & role==2), by(incumbent)
ranksum updateexact if(period==1 & role==2), by(incumbent)
ranksum level1plus 	if(period==1 & role==2), by(incumbent)
ranksum risk 		if(period==1 & role==2), by(incumbent)


***************************************************
* Figure 3: Distribution of correlation awareness *
***************************************************

*** Answer tos Q1
graph twoway ///
(histogram guess1 if(period==1 ), color(sea%90)  xlabel(0(5)20, nogrid) xtitle(Answers to Q1) discrete legend(off))  ///
(kdensity  guess1 if(period==1 ), color(black%90) xlabel(0(5)20, nogrid) lpattern() bwidth(1.0) ) 

*** Answer tos Q2
graph twoway ///
(histogram guess2 if(period==1 ), color(sea%90)  xlabel(0(5)20, nogrid) xtitle(Answers to Q2) discrete legend(off))  ///
(kdensity  guess2 if(period==1 ), color(black%90) xlabel(0(5)20, nogrid) lpattern() bw(1.5) ) 


******************************************************************
* Figure 4: Distribution of strategic reasoning in guessing game *
******************************************************************

histogram guess if(period==1 ), color(sea%90) xlabel(0(10)100, nogrid)  discrete width(5) kdensity



*** --------------------------------------------------- ***
***       RESULTS: Candidate behavior		*** 
*** --------------------------------------------------- ***


********************************************************************
*** Table 3: Proportion of platform played by type and treatment ***
********************************************************************

preserve
gen Platformgrey=(platform==1) if role==1&colorpolitician==1
gen Platformsame=((platform==2&colorpolitician==2)|(platform==3&colorpolitician==3)) if role==1&colorpolitician==1
gen Platformother=((platform==2&colorpolitician==3)|(platform==3&colorpolitician==2)) if role==1&colorpolitician==1
gen Platformlater=(platform==4) if role==1&colorpolitician==1  
estpost summarize Platformgrey Platformsame Platformother Platformlater if incumbent==1
esttab ., cell(mean(fmt(2))) noobs
est store A
estpost summarize Platformgrey Platformsame Platformother Platformlater if incumbent==0
esttab ., cell(mean(fmt(2))) noobs
est store B
esttab B A, cells("mean") noobs
restore
***-----------***
*compute averages manually
display (0.0162003+0.0132548)/2
display (0.0197368+0.0180921)/2
***-----------***
preserve
gen Platformgrey=(platform==1) if role==1&colorpolitician>1
gen Platformsame=((platform==2&colorpolitician==2)|(platform==3&colorpolitician==3)) if role==1&colorpolitician>1
gen Platformother=((platform==2&colorpolitician==3)|(platform==3&colorpolitician==2)) if role==1&colorpolitician>1
gen Platformlater=(platform==4) if role==1&colorpolitician>1
estpost summarize Platformgrey Platformsame Platformother Platformlater if incumbent==1
esttab ., cell(mean(fmt(2))) noobs
est store C
estpost summarize Platformgrey Platformsame Platformother Platformlater if incumbent==0
esttab ., cell(mean(fmt(2))) noobs
est store D
esttab D C, cells("mean") noobs
restore

*export table to Stata
esttab B A D C , cells("mean") noobs
*export table to LaTex
*esttab B A D C  using Table3.tex, cells("mean(fmt(%5.2f))") replace


*************************************************
* Figure 5: Playing ambiguous platform (PART A) *
*************************************************

*** TREATMENT COMPARISON: CORRELATION AWARENESS

preserve

collapse (mean) noncommit  if(role==1&colorpolitician>1), by(incumbent updateexact)

statsby mean=r(mean) ub=r(ub) lb=r(lb) N=r(N) sd=r(sd), by(incumbent updateexact  ) level(95) clear: ci mean noncommit

list
		
twoway	(bar mean updateexact, color(sea%70) barw(0.9) by(incumbent, legend(off) )) , xlabel(0 "CA=0" 1 "CA=1", nogrid ) xtitle("Correlation awareness (CA)") ylabel(0(.1).5, grid) ytitle("Proportion ambiguous platforms") title("") 
		
restore

*************************************************
* Figure 5: Playing ambiguous platform (PART B) *
*************************************************

*** TREATMENT COMPARISON: STRATEGIC REASONING
		
preserve

collapse (mean) noncommit  if(role==1&colorpolitician>1), by(incumbent level1plus)

statsby mean=r(mean) ub=r(ub) lb=r(lb) N=r(N) sd=r(sd), by(incumbent  level1plus ) level(95) clear: ci mean noncommit 

list
		
twoway	(bar mean level1plus,   color(sea%70) barw(0.9) by(incumbent, legend(off)   )) , 	xlabel(0 "SR=0" 1 "SR=1", nogrid ) xtitle("Strategic reasoning (SR)")  ylabel(0(.1).5, grid) ytitle("Proportion ambiguous platforms") title("") 
		
restore


****************************
* Numbers used in the text *
****************************


*** Correlation awareness (CA) ***

*gen updateexact=1
*replace updateexact=0 if guess1<9|guess1>11|guess2<16|guess2>18

sum updateexact if period==1 & role==1, detail
sum updateexact if period==1 & role==2 , detail


*proportion of update exact in sample
sum updateexact if period==1, detail

sum 	updateexact if(period==1 & role==1 & incumbent==0)
sum 	updateexact if(period==1 & role==1 & incumbent==1)
ranksum updateexact if(period==1 & role==1), by(incumbent)

sum 	updateexact if(period==1 & role==2 & incumbent==0)
sum 	updateexact if(period==1 & role==2 & incumbent==1)
ranksum updateexact if(period==1 & role==2), by(incumbent)


***(in discussion)
*Candidates:
*Difference in proportion of UPDATEEXACT by treat
sum 	updateexact if(period==1 & role==1 & incumbent==0)
sum 	updateexact if(period==1 & role==1 & incumbent==1)
ranksum updateexact if(period==1 & role==1), by(incumbent)

*Voters:
*Difference in proportion of UPDATEEXACT by treat
sum 	updateexact if(period==1 & role==2 & incumbent==0)
sum 	updateexact if(period==1 & role==2 & incumbent==1)
ranksum updateexact if(period==1 & role==2), by(incumbent)


*** Strategic reasoning (SR) 	***

* Behavior in beauty contest / guessing game
sum guess if period==1


***(for discussion)
*Candidates:
*Difference in proportion of level1s by treat
sum 	level1plus if(period==1 & role==1 & incumbent==0)
sum 	level1plus if(period==1 & role==1 & incumbent==1)
ranksum level1plus if(period==1 & role==1), by(incumbent)

*Voters:
*Difference in proportion of level1s by treat
sum 	level1plus if(period==1 & role==2 & incumbent==0)
sum 	level1plus if(period==1 & role==2 & incumbent==1)
ranksum level1plus if(period==1 & role==2), by(incumbent)

// pwcorr updateexact level1plus if period==1, sig 

// correlate updateexact  level1plus if period==1 & role==1
// correlate updateexact  level1plus if period==1 & role==2



*** RISK (survey measure: willingness to take risks in general) *** ***
sum risk if(period==1), detail

* Histogram risktaking willingness from ex post questionnaire (SOEP)
histogram risk if(period==1), xlabel(0(1)10, nogrid) color(sea%90) discrete
 
 
 
*** TESTS FOR MAIN TREATMENT DIFFERENCES ***

*** TREATMENT COMPARISON: CORRELATION AWARENESS
*gen incumbent=vote6==.
*gen noncommit=platform==4
mean noncommit if role==1&colorpolitician>1, over(incumbent)


** BETWEEN-TREATMENT noncommit choice 
preserve
collapse (mean) noncommit (mean) incumbent if role==1&colorpolitician>1, by(session)
ranksum noncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore

** Conditional on CA
* BETWEEN-TREATMENT noncommit choice conditional on CA=1
preserve
collapse (mean) noncommit (mean) incumbent if(role==1 & colorpolitician>1 & updateexact==1), by(session)
ranksum noncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore

* BETWEEN-TREATMENT noncommit choice conditional on CA=0
preserve
collapse (mean) noncommit (mean) incumbent if(role==1 & colorpolitician>0 & updateexact==1), by(session)
ranksum noncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore

** Conditional on SR
* BETWEEN-TREATMENT noncommit choice conditional on SR=1
preserve
collapse (mean) noncommit (mean) incumbent if(role==1 & colorpolitician>1 & level1plus==1), by(session)
ranksum noncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore

* BETWEEN-TREATMENT noncommit choice conditional on SR=0

preserve
collapse (mean) noncommit (mean) incumbent if(role==1 & colorpolitician>1 & level1plus==0), by(session)
ranksum noncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore


*** WITHIN TREATMENT difference between CA=1 and CA=0

* WITHIN TREATMENT incumbent=1 comparison by CA

sum noncommit if (role==1 &colorpolitician>1 & incumbent==1 & updateexact==1)
sum noncommit if (role==1 &colorpolitician>1 & incumbent==1 & updateexact==0)

preserve
gen platformlatersoph=(platform==4) if role==1&colorpolitician>1&updateexact==1&incumbent==1
gen platformlaterunsoph=(platform==4) if role==1&colorpolitician>1&updateexact==0&incumbent==1
collapse (mean) platformlatersoph (mean) platformlaterunsoph if role==1&colorpolitician>1&incumbent==1, by(session)
signrank platformlatersoph=platformlaterunsoph
dis r(p_l_exact)
dis r(p_u_exact)
restore

* WITHIN TREATMENT incumbent=0 comparison by CA

sum noncommit if (role==1 &colorpolitician>1 & incumbent==0 & updateexact==1)
sum noncommit if (role==1 &colorpolitician>1 & incumbent==0 & updateexact==0)

preserve
gen platformlatersoph=(platform==4) if role==1&colorpolitician>1&updateexact==1&incumbent==0
gen platformlaterunsoph=(platform==4) if role==1&colorpolitician>1&updateexact==0&incumbent==0
collapse (mean) platformlatersoph (mean) platformlaterunsoph if role==1&colorpolitician>1&incumbent==0, by(session)
signrank platformlatersoph=platformlaterunsoph
dis r(p_l_exact)
dis r(p_u_exact)
restore


*** WITHIN TREATMENT difference between SR=1 and SR=0

* WITHIN TREATMENT incumbent=1 comparison by SR

sum noncommit if (role==1 &colorpolitician>1 & incumbent==1 & level1plus==1)
sum noncommit if (role==1 &colorpolitician>1 & incumbent==1 & level1plus==0)

preserve
gen platformlatersoph=(platform==4) if role==1&colorpolitician>1&level1plus==1&incumbent==1
gen platformlaterunsoph=(platform==4) if role==1&colorpolitician>1&level1plus==0&incumbent==1
collapse (mean) platformlatersoph (mean) platformlaterunsoph if role==1&colorpolitician>1&incumbent==1, by(session)
signrank platformlatersoph=platformlaterunsoph
dis r(p_l_exact)
dis r(p_u_exact)
restore

* WITHIN TREATMENT incumbent=0 comparison by SR

sum noncommit if (role==1 &colorpolitician>1 & incumbent==0 & level1plus==1)
sum noncommit if (role==1 &colorpolitician>1 & incumbent==0 & level1plus==0)

preserve
gen platformlatersoph=(platform==4) if role==1&colorpolitician>1&level1plus==1&incumbent==0
gen platformlaterunsoph=(platform==4) if role==1&colorpolitician>1&level1plus==0&incumbent==0
collapse (mean) platformlatersoph (mean) platformlaterunsoph if role==1&colorpolitician>1&incumbent==0, by(session)
signrank platformlatersoph=platformlaterunsoph
dis r(p_l_exact)
dis r(p_u_exact)
restore



*** ------------------------------------------------------- ***
***       RESULTS: 	Voter behavior							*** 
*** ------------------------------------------------------- ***


*************************************************************************
*** Table 4: Proportion of votes for platform 2 by type and treatment ***
*************************************************************************

estpost tabstat vote1 vote2 vote3 vote4 vote5 vote6 if role==2&colorvoter==1&incumbent==0, statistics(mean) columns(statistics) listwise

*compute averages over rows
**column 1
display (0.0416667+0.0458333)/2
display  .4625 // =vote 4
display (0.5739583+0.6385417)/2

estpost tabstat vote2 vote3 vote4 if role==2&colorvoter==1&incumbent==1, statistics(mean) columns(statistics) listwise
*est store B
*compute averages over rows
**column 2
display (0.021875+0.0322917)/2
display  .0427083 // =vote 4

***compute averages over rows
*column 3
mean vote1 if colorvoter==2&role==2&incumbent==0
mean vote2 if colorvoter==3&role==2&incumbent==0
*take average of number of obs
display ((715*.8965035)+(725*.8662069))/(725+715) 
// =.88125

mean vote2 if colorvoter==2&role==2&incumbent==0
mean vote1 if colorvoter==3&role==2&incumbent==0
*take average of number of obs
display ((715*.0783217)+(725*.0882759))/(725+715) 
// =.08333336

mean vote3 if colorvoter>1&role==2&incumbent==0
// =.5402778 

mean vote4 if colorvoter==2&role==2&incumbent==0
mean vote4 if colorvoter==3&role==2&incumbent==0
*take average of number of obs
display ((715*(1-.0559441))+(725*.9434483))/(725+715)
// =.94374999

mean vote6 if colorvoter==2&role==2&incumbent==0
mean vote5 if colorvoter==3&role==2&incumbent==0
*take average of number of obs
display ((715*.9174825)+(725*.9158621))/(725+715) 
// =.91666667

mean vote5 if colorvoter==2&role==2&incumbent==0
mean vote6 if colorvoter==3&role==2&incumbent==0
*take average of number of obs
display ((715*.0937063)+(725*.0924138))/(725+715) 
// =.09305556

*column 4 
mean vote2 if colorvoter==2&role==2&incumbent==1
mean vote3 if colorvoter==3&role==2&incumbent==1
*take average of number of obs
display ((690*.9043478)+(750*.8573333))/(690+750) 
// =.87986108

mean vote3 if colorvoter==2&role==2&incumbent==1
mean vote2 if colorvoter==3&role==2&incumbent==1
*take average of number of obs
display ((690*.1)+(750*.1026667))/(690+750) 
// =.10138891

mean vote4 if colorvoter>1&role==2&incumbent==1
// =.6277778



****************************************************	
* Figure 6: Voting for ambiguous platform (PART A) *
****************************************************	

*** FIGURE CA - correlation awareness

preserve
* on subject level
collapse (mean) votenoncommit if(role==2&colorvoter>1), by(incumbent  updateexact)

statsby mean=r(mean) ub=r(ub) lb=r(lb) N=r(N) sd=r(sd), by(incumbent updateexact) level(95) clear: ci mean votenoncommit

list

twoway	(bar mean updateexact,   color(sea%70) barw(0.9) by(incumbent, legend(off)   )) , xlabel(0 "CA=0" 1 "CA=1", nogrid ) xtitle("Correlation awareness (CA)") ylabel(0(.1).8, grid) ytitle("Proportion ambiguous platforms")	title("") 
		
restore
		
		
****************************************************	
* Figure 6: Voting for ambiguous platform (PART B) *
****************************************************		

*** FIGURE SR - strategic sophistication
	
preserve
collapse (mean) votenoncommit  if(role==2&colorvoter>1),  by(incumbent level1plus)

statsby mean=r(mean) ub=r(ub) lb=r(lb) N=r(N) sd=r(sd), by(incumbent level1plus) level(95) clear: ci mean votenoncommit

list
		
twoway	(bar mean level1plus,   color(sea%70) barw(0.9) by(incumbent, legend(off)   )) , xlabel(0 "SR=0" 1 "SR=1", nogrid ) xtitle("Strategic reasoning (SR)") ylabel(0(.1).8, grid) ytitle("Proportion ambiguous platforms") title("") 
		
restore



****************************
* Numbers used in the text *
****************************

*main treatment
mean votenoncommit if role==2&colorvoter>1, over(incumbent)

** BETWEEN TREATMENT COMPARISON unconditional 
preserve
collapse (mean) votenoncommit   if role==2 & colorvoter>1 , by(session incumbent)
ranksum votenoncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore


*** VOTER TREATMENT COMPARISON: CORRELATION AWARENESS

*Between treatment comparisons conditional on CA=1

** CA=1 across treatment

* avg numbers
mean votenoncommit if role==2&colorvoter>1&updateexact==1, over(incumbent)

* test on session level
preserve		
collapse (mean) votenoncommit if (role==2 & colorvoter>1 & updateexact==1), by(session incumbent)
ranksum votenoncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore


** CA=0 across treatment

* avg numbers
mean votenoncommit if role==2&colorvoter>1&updateexact==0, over(incumbent)

* test on session level
preserve		
collapse (mean) votenoncommit if (role==2 & colorvoter>1 & updateexact==0), by(session incumbent)
ranksum votenoncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore


*** WITHIN TREATMENT difference between CA=1 and CA=0

* Within Treatment incumbent=1 comparison by CA

* averages
mean votenoncommit if role==2&colorvoter>1&incumbent==1, over(updateexact)


* session level WSR test CA=1 against CA=0

preserve
gen votelatersoph=((vote4==1&incumbent==1)|(vote3==1&incumbent==0)) if role==2&colorvoter>1&updateexact==1&incumbent==1
gen votelaterunsoph=((vote4==1&incumbent==1)|(vote3==1&incumbent==0)) if role==2&colorvoter>1&updateexact==0&incumbent==1
collapse (mean) votelatersoph (mean) votelaterunsoph if role==2&colorvoter>1&incumbent==1, by(session)
signrank votelatersoph=votelaterunsoph
dis r(p_l_exact)
dis r(p_u_exact)
restore


* Within Treatment incumbent=0 comparing CA=1 vs CA=0

* averages
mean votenoncommit if role==2&colorvoter>1&incumbent==0, over(updateexact)


* session level WSR test CA=1 against CA=0

preserve
gen votelatersoph=((vote4==1&incumbent==1)|(vote3==1&incumbent==0)) if role==2&colorvoter>1&updateexact==1&incumbent==0
gen votelaterunsoph=((vote4==1&incumbent==1)|(vote3==1&incumbent==0)) if role==2&colorvoter>1&updateexact==0&incumbent==0
collapse (mean) votelatersoph (mean) votelaterunsoph if role==2&colorvoter>1&incumbent==0, by(session)
signrank votelatersoph=votelaterunsoph
dis r(p_l_exact)
dis r(p_u_exact)
restore



** BETWEEN TREATMENT COMPARISONS 
** SR=1 across treatment

* avg numbers
mean votenoncommit if role==2&colorvoter>1&level1plus==1, over(incumbent)

* test on session level

preserve		
collapse (mean) votenoncommit if (role==2 & colorvoter>1 & level1plus==1), by(session incumbent)
ranksum votenoncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore


* SR=0 across treatment

* avg numbers
mean votenoncommit if role==2&colorvoter>1&level1plus==0, over(incumbent)

* test on session level

preserve		
collapse (mean) votenoncommit if (role==2 & colorvoter>1 & level1plus==0), by(session incumbent)
ranksum votenoncommit, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore


*** WITHIN TREATMENT difference between SR=1 and SR=0

* Within Treatment incumbent=1 comparison by SR

* averages
mean votenoncommit if role==2&colorvoter>1&incumbent==1, over(level1plus)


* session level WSR test SR=1 against SR=0

preserve
gen votelatersoph=((vote4==1&incumbent==1)|(vote3==1&incumbent==0)) if role==2&colorvoter>1&level1plus==1&incumbent==1
gen votelaterunsoph=((vote4==1&incumbent==1)|(vote3==1&incumbent==0)) if role==2&colorvoter>1&level1plus==0&incumbent==1
collapse (mean) votelatersoph (mean) votelaterunsoph if role==2&colorvoter>1&incumbent==1, by(session)
signrank votelatersoph=votelaterunsoph
dis r(p_l_exact)
dis r(p_u_exact)
restore


* Within Treatment incumbent=0 comparing SR=1 vs SR=0

* averages
mean votenoncommit if role==2&colorvoter>1&incumbent==0, over(level1plus)


* session level WSR test SR=1 against SR=0

preserve
gen votelatersoph=((vote4==1&incumbent==1)|(vote3==1&incumbent==0)) if role==2&colorvoter>1&level1plus==1&incumbent==0
gen votelaterunsoph=((vote4==1&incumbent==1)|(vote3==1&incumbent==0)) if role==2&colorvoter>1&level1plus==0&incumbent==0
collapse (mean) votelatersoph (mean) votelaterunsoph if role==2&colorvoter>1&incumbent==0, by(session)
signrank votelatersoph=votelaterunsoph
dis r(p_l_exact)
dis r(p_u_exact)
restore
	
	
	
********************************************************************************
***			APPENDIX													  	 ***	
********************************************************************************	
		


*** -------------------------------------------------------------------------***
***			APPENDIX: ADDITIONAL RESULTS									 ***
*** -------------------------------------------------------------------------***


***************************************************************************
*** Table A1: Platform choice by candidate preference type and treatment ***
***************************************************************************

*Centrist
preserve
gen Platform1=(platform==1) if role==1&colorpolitician==1&incumbent==0
gen Platform2=(platform==2) if role==1&colorpolitician==1&incumbent==0
gen Platform3=(platform==3) if role==1&colorpolitician==1&incumbent==0
gen Platform4=(platform==4) if role==1&colorpolitician==1&incumbent==0
estpost summarize Platform1 Platform2 Platform3 Platform4
esttab ., cell(mean(fmt(2))) noobs
est store Z
restore
preserve
gen Platform1=(platform==1) if role==1&colorpolitician==1&incumbent==1
gen Platform2=(platform==2) if role==1&colorpolitician==1&incumbent==1
gen Platform3=(platform==3) if role==1&colorpolitician==1&incumbent==1
gen Platform4=(platform==4) if role==1&colorpolitician==1&incumbent==1
estpost summarize Platform1 Platform2 Platform3 Platform4
esttab ., cell(mean(fmt(2))) noobs
est store Y
restore
*Rightist
preserve
gen Platform1=(platform==1) if role==1&colorpolitician==2&incumbent==0
gen Platform2=(platform==2) if role==1&colorpolitician==2&incumbent==0
gen Platform3=(platform==3) if role==1&colorpolitician==2&incumbent==0
gen Platform4=(platform==4) if role==1&colorpolitician==2&incumbent==0
estpost summarize Platform1 Platform2 Platform3 Platform4
esttab ., cell(mean(fmt(2))) noobs
est store X
restore
preserve
gen Platform1=(platform==1) if role==1&colorpolitician==2&incumbent==1
gen Platform2=(platform==2) if role==1&colorpolitician==2&incumbent==1
gen Platform3=(platform==3) if role==1&colorpolitician==2&incumbent==1
gen Platform4=(platform==4) if role==1&colorpolitician==2&incumbent==1
estpost summarize Platform1 Platform2 Platform3 Platform4
esttab ., cell(mean(fmt(2))) noobs
est store W 
restore
*Leftist
preserve
gen Platform1=(platform==1) if role==1&colorpolitician==3&incumbent==0
gen Platform2=(platform==2) if role==1&colorpolitician==3&incumbent==0
gen Platform3=(platform==3) if role==1&colorpolitician==3&incumbent==0
gen Platform4=(platform==4) if role==1&colorpolitician==3&incumbent==0
estpost summarize Platform1 Platform2 Platform3 Platform4
esttab ., cell(mean(fmt(2))) noobs
est store V
restore
preserve
gen Platform1=(platform==1) if role==1&colorpolitician==3&incumbent==1
gen Platform2=(platform==2) if role==1&colorpolitician==3&incumbent==1
gen Platform3=(platform==3) if role==1&colorpolitician==3&incumbent==1
gen Platform4=(platform==4) if role==1&colorpolitician==3&incumbent==1
estpost summarize Platform1 Platform2 Platform3 Platform4
esttab ., cell(mean(fmt(2))) noobs
est store U
restore
*export table to Stata 
esttab Z Y X W V U, cells("mean") noobs
*export table to LaTex
*esttab Z Y X W V U using Table5.tex, cells("mean(fmt(%5.2f))") replace 
 

***************************************************************************** 
*** Table A2: Votes for platform 2 by voter preference type and treatment ***
*****************************************************************************

estpost tabstat vote1 vote2 vote3 vote4 vote5 vote6 if role==2&colorvoter==1&incumbent==0, statistics(mean) columns(statistics) listwise
est store A
estpost tabstat vote2 vote3 vote4 if role==2&colorvoter==1&incumbent==1, statistics(mean) columns(statistics) listwise
est store B
estpost tabstat vote1 vote2 vote3 vote4 vote5 vote6 if role==2&colorvoter==2&incumbent==0, statistics(mean) columns(statistics) listwise
est store C
estpost tabstat vote2 vote3 vote4 if role==2&colorvoter==2&incumbent==1, statistics(mean) columns(statistics) listwise
est store D
estpost tabstat vote1 vote2 vote3 vote4 vote5 vote6 if role==2&colorvoter==3&incumbent==0, statistics(mean) columns(statistics) listwise
est store E
estpost tabstat vote2 vote3 vote4 if role==2&colorvoter==3&incumbent==1, statistics(mean) columns(statistics) listwise
est store F
*output to STATA
esttab A B C D E F, cells("mean")
*output to LaTex
*esttab A B C D E F using Table6.tex, cells("mean(fmt(%5.2f))") replace


*********************************************************************
*** Table A3: Non-centrist candidates choosing ambiguous platform ***
***********************************(*********************************

*** CANDIDATE PROBIT REGRESSIONS: 

*m1
eststo: probit noncommit i.incumbent 											if role==1&colorpolitician>1, cluster(session)
*m2
eststo: probit noncommit i.incumbent  i.updateexact i.level1plus risk female age if role==1&colorpolitician>1, cluster(session)
*m3
eststo: probit noncommit i.incumbent##i.updateexact i.incumbent##i.level1plus 	if role==1&colorpolitician>1, cluster(session)

*m4
eststo: probit noncommit i.incumbent##i.updateexact i.incumbent##i.level1plus risk female age if role==1&colorpolitician>1, cluster(session)

*esttab using Table7.tex, replace booktabs  label title(Probit regressions on non-centrist candidates proposing an ambiguous platform) b(3)  se(3) varlabels(_cons "Constant" ) se star(* 0.10 ** 0.05 *** 0.01) stardetach stats(N N_g r2 p, fmt(%9.0g %9.0g %9.3f %9.3f) labels("Number of obs." "Number of groups" "R2" "Wald Prob > chi2" ))


*******************************************************************	
*** Table A4: Non-centrist voters voting for ambiguous platform ***	
*******************************************************************	
	
*** VOTER PROBIT REGRESSIONS: 

*m1
eststo: probit votenoncommit i.incumbent if role==2&colorvoter>1, cluster(session)

*m2
eststo: probit votenoncommit i.incumbent i.updateexact i.level1plus risk female age 	if role==2&colorvoter>1, cluster(session)

*m3
eststo: probit votenoncommit i.incumbent##i.updateexact i.incumbent##i.level1plus 		if role==2&colorvoter>1, cluster(session)


*m4
eststo: probit votenoncommit i.incumbent##i.updateexact i.incumbent##i.level1plus risk female age if role==2&colorvoter>1, cluster(session)


*esttab using Table8.tex, replace booktabs  label title(Probit regressions on non-centrist voters voting for an ambiguous platform) b(3)  se(3) varlabels(_cons "Constant" ) se star(* 0.10 ** 0.05 *** 0.01) stardetach stats(N N_g r2 p, fmt(%9.0g %9.0g %9.3f %9.3f) labels("Number of obs." "Number of groups" "R2" "Wald Prob > chi2" ))




*** --------------------------------------------------------------------------------- ***
***				Appendix: From individual behavior to outcomes					      ***
*** --------------------------------------------------------------------------------- ***


********************************************************************************
*** Table A5: Proportion of platforms in electoral competitions by treatment ***
********************************************************************************

*Treatment BL
preserve
gen bothcenter=(platform==1&oplatform==1) if role==1
gen cenextrem=((platform==1&oplatform==2)|(platform==1&oplatform==3)|(platform==2&oplatform==1)|(platform==3&oplatform==1)) if role==1
gen cenamb=((platform==1&oplatform==4)|(platform==4&oplatform==1)) if role==1
gen bothsame=((platform==2&oplatform==2)|(platform==3&oplatform==3)) if role==1
gen diffextrem=((platform==2&oplatform==3)|(platform==3&oplatform==2)) if role==1
gen extramb=((platform==2&oplatform==4)|(platform==3&oplatform==4)|(platform==4&oplatform==2)|(platform==4&oplatform==3)) if role==1
gen bothamb=(platform==4&oplatform==4) if role==1
estpost tabstat bothcenter cenextrem cenamb bothsame diffextrem extramb bothamb if incumbent==0, statistics(mean) columns(statistics) listwise
est store X1
*compute manually
sum won if ((cenextrem==1&incumbent==0&platform==2)|(cenextrem==1&incumbent==0&platform==3)) 
// =.1498127
sum won if cenamb==1&incumbent==0&platform==4 
// =.1008403
sum won if extramb==1&incumbent==0&platform==4 
// =.2992701
restore

*Treatment KC
preserve
gen bothcenter=(platform==1) if role==1
gen cenextrem=((platform==2)|(platform==3)) if role==1
gen cenamb=(platform==4) if role==1
estpost tabstat bothcenter cenextrem cenamb if incumbent==1, statistics(mean) columns(statistics) listwise
est store X2
*compute manually
sum won if ((cenextrem==1&incumbent==1&platform==2)|(cenextrem==1&incumbent==1&platform==3)) 
// =.1098901
sum won if cenamb==1&incumbent==1&platform==4 
// =.125
restore

***compute p-values for Treatment difference
*bothcenter
preserve
gen bothcentest = 0
replace bothcentest=(platform==1&oplatform==1) if role==1&incumbent==0
replace bothcentest=(platform==1) if role==1&incumbent==1
collapse (mean) bothcentest (mean) incumbent if role==1, by(session)
ranksum bothcentest, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore
*cenextrem
preserve
gen cenextest = 0
replace cenextest=((platform==1&oplatform==2)|(platform==1&oplatform==3)|(platform==2&oplatform==1)|(platform==3&oplatform==1)) if role==1&incumbent==0
replace cenextest=((platform==2)|(platform==3)) if role==1&incumbent==1
collapse (mean) cenextest (mean) incumbent if role==1, by(session)
ranksum cenextest, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore

*cenamb
preserve
gen cenambtest = 0
replace cenambtest=((platform==1&oplatform==4)|(platform==4&oplatform==1)) if role==1&incumbent==0
replace cenambtest=(platform==4) if role==1&incumbent==1
collapse (mean) cenambtest (mean) incumbent if role==1, by(session)
ranksum cenambtest, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore
***compute p-values for proportion of elections won
*center vs. extreme
preserve
gen cenextest = 0
replace cenextest=((platform==1&oplatform==2)|(platform==1&oplatform==3)|(platform==2&oplatform==1)|(platform==3&oplatform==1)) if role==1&incumbent==0
replace cenextest=((platform==2)|(platform==3)) if role==1&incumbent==1
gen exwontest = 0
replace exwontest=(won==1) if ((cenextest==1&incumbent==0&platform==2)|(cenextest==1&incumbent==0&platform==3))
replace exwontest=(won==1) if ((cenextest==1&incumbent==1&platform==2)|(cenextest==1&incumbent==1&platform==3))
gen platformex=(platform==2|platform==3)
collapse (mean) exwontest (mean) incumbent if role==1&cenextest==1&platformex==1, by(session)
ranksum exwontest, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore
*center vs. ambiguous
preserve
gen cenambtest = 0
replace cenambtest=((platform==1&oplatform==4)|(platform==4&oplatform==1)) if role==1&incumbent==0
replace cenambtest=(platform==4) if role==1&incumbent==1
gen ambwontest = 0
replace ambwontest=(won==1) if cenambtest==1&platform==4
collapse (mean) ambwontest (mean) incumbent if role==1&cenambtest==1&platform==4, by(session)
ranksum ambwontest, by(incumbent)
dis r(p_l_exact)
dis r(p_u_exact)
restore

*export table to Stata
esttab X1 X2, cells("mean(fmt(%5.2f))") noobs
*export table to LaTex
*esttab X1 X2 using Table9.tex, noobs cells("mean(fmt(%5.2f))") replace



****************************************************************
*** Table A6: Payoffs of extreme candidates by policy choice ***
****************************************************************

*generate variables needed
preserve
gen Platformgrey=(platform==1) if role==1
gen Platformsame=((platform==2&colorpolitician==2)|(platform==3&colorpolitician==3)) if role==1
gen Platformother=((platform==2&colorpolitician==3)|(platform==3&colorpolitician==2)) if role==1
gen Platformlater=(platform==4) if role==1
*make table
estpost tabstat utility if role==1&colorpolitician>1&Platformgrey==1, statistics(mean count) columns(statistics) by(incumbent)
est store t1
estpost tabstat utility if role==1&colorpolitician>1&Platformsame==1, statistics(mean count) columns(statistics) by(incumbent)
est store t2
estpost tabstat utility if role==1&colorpolitician>1&Platformother==1, statistics(mean count) columns(statistics) by(incumbent)
est store t3
estpost tabstat utility if role==1&colorpolitician>1&Platformlater==1, statistics(mean count) columns(statistics) by(incumbent)
est store t4
restore
*export table to Stata
*esttab t1 t2 t3 t4, cells("mean n") noobs
*export table to LaTex
*esttab t1 t2 t3 t4 using Table10.tex, noobs cells("mean(fmt(%5.2f)) n") replace

gen platformgrey=(platform==1) if role==1
gen platformsame=((platform==2&colorpolitician==2)|(platform==3&colorpolitician==3)) if role==1
gen platformother=((platform==2&colorpolitician==3)|(platform==3&colorpolitician==2)) if role==1
gen platformlater=(platform==4) if role==1

* Own Colour v. Center - BL
preserve
gen utilitygrey=utility if role==1&colorpolitician>1&incumbent==0&platformgrey==1
gen utilitysame=utility if role==1&colorpolitician>1&incumbent==0&platformsame==1
collapse (mean) utilitygrey (mean) utilitysame if role==1&colorpolitician>1&incumbent==0, by(session)
signrank utilitygrey=utilitysame
dis r(p_l_exact)
dis r(p_u_exact)
restore

* Ambiguous v. Center - BL
preserve
gen utilitygrey=utility if role==1&colorpolitician>1&incumbent==0&platformgrey==1
gen utilitylater=utility if role==1&colorpolitician>1&incumbent==0&platformlater==1
collapse (mean) utilitygrey (mean) utilitylater if role==1&colorpolitician>1&incumbent==0, by(session)
signrank utilitygrey=utilitylater
dis r(p_l_exact)
dis r(p_u_exact)
restore

* Own Colour v. Center - KC
preserve
gen utilitygrey=utility if role==1&colorpolitician>1&incumbent==0&platformgrey==1
gen utilitysame=utility if role==1&colorpolitician>1&incumbent==0&platformsame==1
collapse (mean) utilitygrey (mean) utilitysame if role==1&colorpolitician>1&incumbent==0, by(session)
signrank utilitygrey=utilitysame
dis r(p_l_exact)
dis r(p_u_exact)
restore

* Ambiguous v. Center - KC
preserve
gen utilitygrey=utility if role==1&colorpolitician>1&incumbent==0&platformgrey==1
gen utilitylater=utility if role==1&colorpolitician>1&incumbent==0&platformlater==1
collapse (mean) utilitygrey (mean) utilitylater if role==1&colorpolitician>1&incumbent==0, by(session)
signrank utilitygrey=utilitylater
dis r(p_l_exact)
dis r(p_u_exact)
restore



*** ----- ENDNOTES FOR Stata-packages ----- ***
	grstyle clear	
*** --------------------------------------- ***

***********
*** END ***
***********
